home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / dist / gdb / m2-exp.tab.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-11  |  59.4 KB  |  2,029 lines

  1.  
  2. /*  A Bison parser, made from ./m2-exp.y  */
  3.  
  4. #define    INT    258
  5. #define    HEX    259
  6. #define    ERROR    260
  7. #define    UINT    261
  8. #define    TRUE    262
  9. #define    FALSE    263
  10. #define    CHAR    264
  11. #define    FLOAT    265
  12. #define    STRING    266
  13. #define    NAME    267
  14. #define    BLOCKNAME    268
  15. #define    IDENT    269
  16. #define    VARNAME    270
  17. #define    TYPENAME    271
  18. #define    SIZE    272
  19. #define    CAP    273
  20. #define    ORD    274
  21. #define    HIGH    275
  22. #define    ABS    276
  23. #define    MIN_FUNC    277
  24. #define    MAX_FUNC    278
  25. #define    FLOAT_FUNC    279
  26. #define    VAL    280
  27. #define    CHR    281
  28. #define    ODD    282
  29. #define    TRUNC    283
  30. #define    INC    284
  31. #define    DEC    285
  32. #define    INCL    286
  33. #define    EXCL    287
  34. #define    COLONCOLON    288
  35. #define    LAST    289
  36. #define    REGNAME    290
  37. #define    INTERNAL_VAR    291
  38. #define    ABOVE_COMMA    292
  39. #define    ASSIGN    293
  40. #define    LEQ    294
  41. #define    GEQ    295
  42. #define    NOTEQUAL    296
  43. #define    IN    297
  44. #define    OROR    298
  45. #define    ANDAND    299
  46. #define    DIV    300
  47. #define    MOD    301
  48. #define    UNARY    302
  49. #define    DOT    303
  50. #define    NOT    304
  51. #define    QID    305
  52.  
  53. #line 31 "./m2-exp.y"
  54.  
  55. #include <stdio.h>
  56. #include <string.h>
  57. #include "defs.h"
  58. #include "symtab.h"
  59. #include "gdbtypes.h"
  60. #include "frame.h"
  61. #include "expression.h"
  62. #include "language.h"
  63. #include "value.h"
  64. #include "parser-defs.h"
  65. #include "bfd.h"
  66. #include "symfile.h"
  67. #include "objfiles.h"
  68.  
  69. /* Ensure that if the generated parser contains any calls to malloc/realloc,
  70.    that they get mapped to xmalloc/xrealloc. */
  71.  
  72. #define malloc    xmalloc
  73. #define realloc    xrealloc
  74.  
  75. /* These MUST be included in any grammar file!!!!
  76.    Please choose unique names! */
  77. #define    yymaxdepth m2_maxdepth
  78. #define    yyparse    m2_parse
  79. #define    yylex    m2_lex
  80. #define    yyerror    m2_error
  81. #define    yylval    m2_lval
  82. #define    yychar    m2_char
  83. #define    yydebug    m2_debug
  84. #define    yypact    m2_pact
  85. #define    yyr1    m2_r1
  86. #define    yyr2    m2_r2
  87. #define    yydef    m2_def
  88. #define    yychk    m2_chk
  89. #define    yypgo    m2_pgo
  90. #define    yyact    m2_act
  91. #define    yyexca    m2_exca
  92. #define yyerrflag m2_errflag
  93. #define yynerrs    m2_nerrs
  94. #define    yyps    m2_ps
  95. #define    yypv    m2_pv
  96. #define    yys    m2_s
  97. #define    yy_yys    m2_yys
  98. #define    yystate    m2_state
  99. #define    yytmp    m2_tmp
  100. #define    yyv    m2_v
  101. #define    yy_yyv    m2_yyv
  102. #define    yyval    m2_val
  103. #define    yylloc    m2_lloc
  104.  
  105. #if 0
  106. static char *
  107. make_qualname PARAMS ((char *, char *));
  108. #endif
  109.  
  110. static int
  111. parse_number PARAMS ((int));
  112.  
  113. static int
  114. yylex PARAMS ((void));
  115.  
  116. static void
  117. yyerror PARAMS ((char *));
  118.  
  119. int
  120. yyparse PARAMS ((void));
  121.  
  122. /* The sign of the number being parsed. */
  123. int number_sign = 1;
  124.  
  125. /* The block that the module specified by the qualifer on an identifer is
  126.    contained in, */
  127. struct block *modblock=0;
  128.  
  129. /* #define    YYDEBUG    1 */
  130.  
  131.  
  132. #line 114 "./m2-exp.y"
  133. typedef union
  134.   {
  135.     LONGEST lval;
  136.     unsigned LONGEST ulval;
  137.     double dval;
  138.     struct symbol *sym;
  139.     struct type *tval;
  140.     struct stoken sval;
  141.     int voidval;
  142.     struct block *bval;
  143.     enum exp_opcode opcode;
  144.     struct internalvar *ivar;
  145.  
  146.     struct type **tvec;
  147.     int *ivec;
  148.   } YYSTYPE;
  149.  
  150. #ifndef YYLTYPE
  151. typedef
  152.   struct yyltype
  153.     {
  154.       int timestamp;
  155.       int first_line;
  156.       int first_column;
  157.       int last_line;
  158.       int last_column;
  159.       char *text;
  160.    }
  161.   yyltype;
  162.  
  163. #define YYLTYPE yyltype
  164. #endif
  165.  
  166. #include <stdio.h>
  167.  
  168. #ifndef __STDC__
  169. #define const
  170. #endif
  171.  
  172.  
  173.  
  174. #define    YYFINAL        185
  175. #define    YYFLAG        -32768
  176. #define    YYNTBASE    70
  177.  
  178. #define YYTRANSLATE(x) ((unsigned)(x) <= 305 ? yytranslate[x] : 84)
  179.  
  180. static const char yytranslate[] = {     0,
  181.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  182.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  183.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  184.      2,     2,     2,     2,    46,     2,     2,    50,     2,    62,
  185.     66,    54,    52,    37,    53,     2,    55,     2,     2,     2,
  186.      2,     2,     2,     2,     2,     2,     2,     2,     2,    40,
  187.     44,    41,     2,    51,     2,     2,     2,     2,     2,     2,
  188.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  189.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  190.     61,     2,    69,    59,     2,     2,     2,     2,     2,     2,
  191.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  192.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  193.      2,     2,    67,     2,    68,    64,     2,     2,     2,     2,
  194.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  195.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  196.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  197.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  198.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  199.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  200.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  201.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  202.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  203.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  204.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  205.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  206.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  207.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  208.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  209.     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  210.     36,    38,    39,    42,    43,    45,    47,    48,    49,    56,
  211.     57,    58,    60,    63,    65
  212. };
  213.  
  214. static const short yyrline[] = {     0,
  215.    183,   184,   187,   196,   199,   201,   206,   210,   214,   215,
  216.    218,   222,   226,   230,   234,   240,   246,   250,   256,   260,
  217.    264,   268,   273,   277,   283,   287,   293,   299,   302,   306,
  218.    310,   313,   315,   321,   326,   332,   336,   342,   345,   349,
  219.    354,   359,   364,   370,   376,   384,   388,   392,   396,   400,
  220.    404,   408,   412,   416,   418,   422,   426,   430,   434,   438,
  221.    442,   446,   450,   457,   463,   469,   476,   485,   493,   500,
  222.    504,   510,   516,   523,   530,   534,   543,   555,   562,   569,
  223.    583,   656
  224. };
  225.  
  226. static const char * const yytname[] = {     0,
  227. "error","$illegal.","INT","HEX","ERROR","UINT","TRUE","FALSE","CHAR","FLOAT",
  228. "STRING","NAME","BLOCKNAME","IDENT","VARNAME","TYPENAME","SIZE","CAP","ORD","HIGH",
  229. "ABS","MIN_FUNC","MAX_FUNC","FLOAT_FUNC","VAL","CHR","ODD","TRUNC","INC","DEC",
  230. "INCL","EXCL","COLONCOLON","LAST","REGNAME","INTERNAL_VAR","','","ABOVE_COMMA","ASSIGN","'<'",
  231. "'>'","LEQ","GEQ","'='","NOTEQUAL","'#'","IN","OROR","ANDAND","'&'",
  232. "'@'","'+'","'-'","'*'","'/'","DIV","MOD","UNARY","'^'","DOT",
  233. "'['","'('","NOT","'~'","QID","')'","'{'","'}'","']'","start"
  234. };
  235.  
  236. static const short yyr1[] = {     0,
  237.     70,    70,    71,    72,    73,    72,    72,    72,    74,    74,
  238.     72,    72,    72,    72,    72,    72,    72,    72,    72,    72,
  239.     72,    72,    72,    72,    72,    72,    72,    72,    72,    72,
  240.     72,    75,    75,    76,    72,    77,    72,    78,    78,    78,
  241.     79,    79,    72,    72,    72,    72,    72,    72,    72,    72,
  242.     72,    72,    72,    72,    72,    72,    72,    72,    72,    72,
  243.     72,    72,    72,    72,    72,    72,    72,    72,    72,    72,
  244.     72,    72,    72,    72,    80,    81,    81,    82,    82,    82,
  245.     82,    83
  246. };
  247.  
  248. static const short yyr2[] = {     0,
  249.      1,     1,     1,     2,     0,     3,     2,     2,     1,     1,
  250.      4,     4,     4,     4,     4,     4,     4,     6,     4,     4,
  251.      4,     2,     4,     6,     4,     6,     3,     1,     3,     6,
  252.      6,     3,     4,     0,     5,     0,     5,     0,     1,     3,
  253.      1,     3,     4,     4,     3,     3,     3,     3,     3,     3,
  254.      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
  255.      3,     3,     3,     1,     1,     1,     1,     1,     1,     1,
  256.      1,     1,     4,     1,     1,     1,     3,     1,     1,     3,
  257.      1,     1
  258. };
  259.  
  260. static const short yydefact[] = {     0,
  261.     66,    67,    64,    65,    68,    69,    74,    81,    76,    82,
  262.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  263.      0,     0,     0,     0,     0,     0,    71,    72,    79,     0,
  264.      5,     0,     9,    10,    38,     2,     1,     0,    28,     0,
  265.     78,    70,     3,     0,    22,     0,     0,     0,     0,     0,
  266.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  267.      0,     7,     0,     0,    39,     0,     0,     0,     0,     0,
  268.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  269.      0,     0,     0,     0,     0,     0,     4,     0,    34,    36,
  270.      8,     0,     0,    38,     0,     0,     0,     0,     0,     0,
  271.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  272.      6,    45,     0,    32,     0,    63,    58,    59,    56,    57,
  273.     53,    54,    55,    38,    29,     0,    62,    60,    61,    46,
  274.     51,    52,    47,    48,    49,    50,    27,     0,    38,    80,
  275.     77,     0,     0,    73,    11,    12,    14,    13,    15,    16,
  276.     17,     0,    19,    20,    21,     0,    23,     0,    25,     0,
  277.      0,    40,    43,    41,     0,     0,    44,    33,     0,     0,
  278.      0,     0,     0,     0,    35,    37,    18,    24,    26,    30,
  279.     31,    42,     0,     0,     0
  280. };
  281.  
  282. static const short yydefgoto[] = {   183,
  283.     36,    65,    63,    38,    39,   138,   139,    66,   165,    40,
  284.     41,    42,    46
  285. };
  286.  
  287. static const short yypact[] = {   159,
  288. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  289.    221,   -53,   -52,   -31,   -23,   -21,   -20,   -19,   -11,    14,
  290.     26,    27,    29,    30,    35,    36,-32768,-32768,-32768,   159,
  291. -32768,   159,-32768,-32768,   159,-32768,   776,   159,-32768,    -4,
  292.     66,-32768,   -22,   159,     5,   -22,   159,   159,   159,   159,
  293.     17,    17,   159,    17,   159,   159,   159,   159,   159,   159,
  294.    159,     5,   159,   306,   776,   -33,   -40,   159,   159,   159,
  295.    159,   159,   159,   159,   159,   -13,   159,   159,   159,   159,
  296.    159,   159,   159,   159,   159,   159,-32768,    50,-32768,-32768,
  297.      5,    -6,   159,   159,    28,   334,   362,   390,   418,    34,
  298.     39,   446,    64,   474,   502,   530,   250,   278,   726,   752,
  299.      5,-32768,   159,-32768,   159,   800,   -36,   -36,   -36,   -36,
  300.    -36,   -36,   -36,   159,-32768,    40,    70,    88,    88,   144,
  301.    204,   204,     5,     5,     5,     5,-32768,   159,   159,-32768,
  302. -32768,   558,   -32,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  303. -32768,   159,-32768,-32768,-32768,   159,-32768,   159,-32768,   159,
  304.    159,   776,     5,   776,   -35,   -29,-32768,-32768,   586,   614,
  305.    642,   670,   698,   159,-32768,-32768,-32768,-32768,-32768,-32768,
  306. -32768,   776,   102,   108,-32768
  307. };
  308.  
  309. static const short yypgoto[] = {-32768,
  310. -32768,     0,-32768,-32768,    33,-32768,-32768,   -93,-32768,-32768,
  311. -32768,-32768,    52
  312. };
  313.  
  314.  
  315. #define    YYLAST        862
  316.  
  317.  
  318. static const short yytable[] = {    37,
  319.    143,   174,    10,   113,   113,   140,   141,   113,    47,    48,
  320.     45,    77,    78,    79,    80,    81,    82,    83,    84,    85,
  321.     86,    93,    87,    88,    89,    90,    94,   115,    92,    62,
  322.     49,    64,    10,   175,   114,   168,   176,    91,    50,    93,
  323.     51,    52,    53,    64,    94,   166,    96,    97,    98,    99,
  324.     54,    43,   102,   124,   104,   105,   106,   107,   108,   109,
  325.    110,   137,   111,    87,    88,    89,    90,   116,   117,   118,
  326.    119,   120,   121,   122,   123,    55,   127,   128,   129,   130,
  327.    131,   132,   133,   134,   135,   136,    67,    56,    57,    93,
  328.     58,    59,   142,   144,    94,    95,    60,    61,   -75,   149,
  329.    152,   184,   100,   101,   150,   103,    94,   185,   125,     0,
  330.      0,     0,   162,     0,   163,     0,     0,     0,    78,    79,
  331.     80,    81,    82,    83,    84,    85,    86,   126,    87,    88,
  332.     89,    90,     0,     0,     0,     0,     0,   164,    80,    81,
  333.     82,    83,    84,    85,    86,     0,    87,    88,    89,    90,
  334.      0,   169,     0,     0,     0,   170,     0,   171,     0,   172,
  335.    173,     1,     0,     0,     2,     3,     4,     5,     6,     7,
  336.      8,     9,     0,   182,    10,    11,    12,    13,    14,    15,
  337.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  338.     26,     0,    27,    28,    29,    81,    82,    83,    84,    85,
  339.     86,     0,    87,    88,    89,    90,     0,     0,     0,     0,
  340.     30,    31,     0,     0,     0,     0,     0,     0,     0,     0,
  341.     32,    33,    34,     1,     0,    35,     2,     3,     4,     5,
  342.      6,     7,     8,     9,     0,     0,    10,    11,    12,    13,
  343.     14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
  344.     24,    25,    26,     0,    27,    28,    29,    83,    84,    85,
  345.     86,     0,    87,    88,    89,    90,     0,     0,     0,     0,
  346.      0,     0,    30,    31,     0,     0,     0,     0,     0,     0,
  347.      0,     0,    44,    33,    34,     0,   156,    35,    68,    69,
  348.     70,    71,    72,    73,    74,    75,    76,    77,    78,    79,
  349.     80,    81,    82,    83,    84,    85,    86,     0,    87,    88,
  350.     89,    90,     0,     0,   158,   157,    68,    69,    70,    71,
  351.     72,    73,    74,    75,    76,    77,    78,    79,    80,    81,
  352.     82,    83,    84,    85,    86,     0,    87,    88,    89,    90,
  353.      0,     0,     0,   159,    68,    69,    70,    71,    72,    73,
  354.     74,    75,    76,    77,    78,    79,    80,    81,    82,    83,
  355.     84,    85,    86,     0,    87,    88,    89,    90,     0,     0,
  356.      0,   112,    68,    69,    70,    71,    72,    73,    74,    75,
  357.     76,    77,    78,    79,    80,    81,    82,    83,    84,    85,
  358.     86,     0,    87,    88,    89,    90,     0,     0,     0,   145,
  359.     68,    69,    70,    71,    72,    73,    74,    75,    76,    77,
  360.     78,    79,    80,    81,    82,    83,    84,    85,    86,     0,
  361.     87,    88,    89,    90,     0,     0,     0,   146,    68,    69,
  362.     70,    71,    72,    73,    74,    75,    76,    77,    78,    79,
  363.     80,    81,    82,    83,    84,    85,    86,     0,    87,    88,
  364.     89,    90,     0,     0,     0,   147,    68,    69,    70,    71,
  365.     72,    73,    74,    75,    76,    77,    78,    79,    80,    81,
  366.     82,    83,    84,    85,    86,     0,    87,    88,    89,    90,
  367.      0,     0,     0,   148,    68,    69,    70,    71,    72,    73,
  368.     74,    75,    76,    77,    78,    79,    80,    81,    82,    83,
  369.     84,    85,    86,     0,    87,    88,    89,    90,     0,     0,
  370.      0,   151,    68,    69,    70,    71,    72,    73,    74,    75,
  371.     76,    77,    78,    79,    80,    81,    82,    83,    84,    85,
  372.     86,     0,    87,    88,    89,    90,     0,     0,     0,   153,
  373.     68,    69,    70,    71,    72,    73,    74,    75,    76,    77,
  374.     78,    79,    80,    81,    82,    83,    84,    85,    86,     0,
  375.     87,    88,    89,    90,     0,     0,     0,   154,    68,    69,
  376.     70,    71,    72,    73,    74,    75,    76,    77,    78,    79,
  377.     80,    81,    82,    83,    84,    85,    86,     0,    87,    88,
  378.     89,    90,     0,     0,     0,   155,    68,    69,    70,    71,
  379.     72,    73,    74,    75,    76,    77,    78,    79,    80,    81,
  380.     82,    83,    84,    85,    86,     0,    87,    88,    89,    90,
  381.      0,     0,     0,   167,    68,    69,    70,    71,    72,    73,
  382.     74,    75,    76,    77,    78,    79,    80,    81,    82,    83,
  383.     84,    85,    86,     0,    87,    88,    89,    90,     0,     0,
  384.      0,   177,    68,    69,    70,    71,    72,    73,    74,    75,
  385.     76,    77,    78,    79,    80,    81,    82,    83,    84,    85,
  386.     86,     0,    87,    88,    89,    90,     0,     0,     0,   178,
  387.     68,    69,    70,    71,    72,    73,    74,    75,    76,    77,
  388.     78,    79,    80,    81,    82,    83,    84,    85,    86,     0,
  389.     87,    88,    89,    90,     0,     0,     0,   179,    68,    69,
  390.     70,    71,    72,    73,    74,    75,    76,    77,    78,    79,
  391.     80,    81,    82,    83,    84,    85,    86,     0,    87,    88,
  392.     89,    90,     0,     0,     0,   180,    68,    69,    70,    71,
  393.     72,    73,    74,    75,    76,    77,    78,    79,    80,    81,
  394.     82,    83,    84,    85,    86,     0,    87,    88,    89,    90,
  395.      0,     0,   160,   181,    68,    69,    70,    71,    72,    73,
  396.     74,    75,    76,    77,    78,    79,    80,    81,    82,    83,
  397.     84,    85,    86,     0,    87,    88,    89,    90,   161,     0,
  398.     68,    69,    70,    71,    72,    73,    74,    75,    76,    77,
  399.     78,    79,    80,    81,    82,    83,    84,    85,    86,     0,
  400.     87,    88,    89,    90,    68,    69,    70,    71,    72,    73,
  401.     74,    75,    76,    77,    78,    79,    80,    81,    82,    83,
  402.     84,    85,    86,     0,    87,    88,    89,    90,-32768,    69,
  403.     70,    71,    72,    73,    74,    75,    76,    77,    78,    79,
  404.     80,    81,    82,    83,    84,    85,    86,     0,    87,    88,
  405.     89,    90
  406. };
  407.  
  408. static const short yycheck[] = {     0,
  409.     94,    37,    16,    37,    37,    12,    13,    37,    62,    62,
  410.     11,    48,    49,    50,    51,    52,    53,    54,    55,    56,
  411.     57,    62,    59,    60,    61,    62,    67,    68,    33,    30,
  412.     62,    32,    16,    69,    68,    68,    66,    38,    62,    62,
  413.     62,    62,    62,    44,    67,   139,    47,    48,    49,    50,
  414.     62,     0,    53,    67,    55,    56,    57,    58,    59,    60,
  415.     61,    12,    63,    59,    60,    61,    62,    68,    69,    70,
  416.     71,    72,    73,    74,    75,    62,    77,    78,    79,    80,
  417.     81,    82,    83,    84,    85,    86,    35,    62,    62,    62,
  418.     62,    62,    93,    66,    67,    44,    62,    62,    33,    66,
  419.     37,     0,    51,    52,    66,    54,    67,     0,    76,    -1,
  420.     -1,    -1,   113,    -1,   115,    -1,    -1,    -1,    49,    50,
  421.     51,    52,    53,    54,    55,    56,    57,    76,    59,    60,
  422.     61,    62,    -1,    -1,    -1,    -1,    -1,   138,    51,    52,
  423.     53,    54,    55,    56,    57,    -1,    59,    60,    61,    62,
  424.     -1,   152,    -1,    -1,    -1,   156,    -1,   158,    -1,   160,
  425.    161,     3,    -1,    -1,     6,     7,     8,     9,    10,    11,
  426.     12,    13,    -1,   174,    16,    17,    18,    19,    20,    21,
  427.     22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
  428.     32,    -1,    34,    35,    36,    52,    53,    54,    55,    56,
  429.     57,    -1,    59,    60,    61,    62,    -1,    -1,    -1,    -1,
  430.     52,    53,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  431.     62,    63,    64,     3,    -1,    67,     6,     7,     8,     9,
  432.     10,    11,    12,    13,    -1,    -1,    16,    17,    18,    19,
  433.     20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
  434.     30,    31,    32,    -1,    34,    35,    36,    54,    55,    56,
  435.     57,    -1,    59,    60,    61,    62,    -1,    -1,    -1,    -1,
  436.     -1,    -1,    52,    53,    -1,    -1,    -1,    -1,    -1,    -1,
  437.     -1,    -1,    62,    63,    64,    -1,    37,    67,    39,    40,
  438.     41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
  439.     51,    52,    53,    54,    55,    56,    57,    -1,    59,    60,
  440.     61,    62,    -1,    -1,    37,    66,    39,    40,    41,    42,
  441.     43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
  442.     53,    54,    55,    56,    57,    -1,    59,    60,    61,    62,
  443.     -1,    -1,    -1,    66,    39,    40,    41,    42,    43,    44,
  444.     45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
  445.     55,    56,    57,    -1,    59,    60,    61,    62,    -1,    -1,
  446.     -1,    66,    39,    40,    41,    42,    43,    44,    45,    46,
  447.     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
  448.     57,    -1,    59,    60,    61,    62,    -1,    -1,    -1,    66,
  449.     39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
  450.     49,    50,    51,    52,    53,    54,    55,    56,    57,    -1,
  451.     59,    60,    61,    62,    -1,    -1,    -1,    66,    39,    40,
  452.     41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
  453.     51,    52,    53,    54,    55,    56,    57,    -1,    59,    60,
  454.     61,    62,    -1,    -1,    -1,    66,    39,    40,    41,    42,
  455.     43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
  456.     53,    54,    55,    56,    57,    -1,    59,    60,    61,    62,
  457.     -1,    -1,    -1,    66,    39,    40,    41,    42,    43,    44,
  458.     45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
  459.     55,    56,    57,    -1,    59,    60,    61,    62,    -1,    -1,
  460.     -1,    66,    39,    40,    41,    42,    43,    44,    45,    46,
  461.     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
  462.     57,    -1,    59,    60,    61,    62,    -1,    -1,    -1,    66,
  463.     39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
  464.     49,    50,    51,    52,    53,    54,    55,    56,    57,    -1,
  465.     59,    60,    61,    62,    -1,    -1,    -1,    66,    39,    40,
  466.     41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
  467.     51,    52,    53,    54,    55,    56,    57,    -1,    59,    60,
  468.     61,    62,    -1,    -1,    -1,    66,    39,    40,    41,    42,
  469.     43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
  470.     53,    54,    55,    56,    57,    -1,    59,    60,    61,    62,
  471.     -1,    -1,    -1,    66,    39,    40,    41,    42,    43,    44,
  472.     45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
  473.     55,    56,    57,    -1,    59,    60,    61,    62,    -1,    -1,
  474.     -1,    66,    39,    40,    41,    42,    43,    44,    45,    46,
  475.     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
  476.     57,    -1,    59,    60,    61,    62,    -1,    -1,    -1,    66,
  477.     39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
  478.     49,    50,    51,    52,    53,    54,    55,    56,    57,    -1,
  479.     59,    60,    61,    62,    -1,    -1,    -1,    66,    39,    40,
  480.     41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
  481.     51,    52,    53,    54,    55,    56,    57,    -1,    59,    60,
  482.     61,    62,    -1,    -1,    -1,    66,    39,    40,    41,    42,
  483.     43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
  484.     53,    54,    55,    56,    57,    -1,    59,    60,    61,    62,
  485.     -1,    -1,    37,    66,    39,    40,    41,    42,    43,    44,
  486.     45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
  487.     55,    56,    57,    -1,    59,    60,    61,    62,    37,    -1,
  488.     39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
  489.     49,    50,    51,    52,    53,    54,    55,    56,    57,    -1,
  490.     59,    60,    61,    62,    39,    40,    41,    42,    43,    44,
  491.     45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
  492.     55,    56,    57,    -1,    59,    60,    61,    62,    39,    40,
  493.     41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
  494.     51,    52,    53,    54,    55,    56,    57,    -1,    59,    60,
  495.     61,    62
  496. };
  497. #define YYPURE 1
  498.  
  499. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  500. #line 3 "bison.simple"
  501.  
  502. /* Skeleton output parser for bison,
  503.    Copyright (C) 1984 Bob Corbett and Richard Stallman
  504.  
  505.    This program is free software; you can redistribute it and/or modify
  506.    it under the terms of the GNU General Public License as published by
  507.    the Free Software Foundation; either version 1, or (at your option)
  508.    any later version.
  509.  
  510.    This program is distributed in the hope that it will be useful,
  511.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  512.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  513.    GNU General Public License for more details.
  514.  
  515.    You should have received a copy of the GNU General Public License
  516.    along with this program; if not, write to the Free Software
  517.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  518.  
  519.  
  520. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  521. #include <alloca.h>
  522. #endif
  523.  
  524. /* This is the parser code that is written into each bison parser
  525.   when the %semantic_parser declaration is not specified in the grammar.
  526.   It was written by Richard Stallman by simplifying the hairy parser
  527.   used when %semantic_parser is specified.  */
  528.  
  529. /* Note: there must be only one dollar sign in this file.
  530.    It is replaced by the list of actions, each action
  531.    as one case of the switch.  */
  532.  
  533. #define yyerrok        (yyerrstatus = 0)
  534. #define yyclearin    (yychar = YYEMPTY)
  535. #define YYEMPTY        -2
  536. #define YYEOF        0
  537. #define YYFAIL        goto yyerrlab;
  538. #define YYACCEPT    return(0)
  539. #define YYABORT     return(1)
  540. #define YYERROR        goto yyerrlab
  541.  
  542. #define YYTERROR    1
  543. #define YYERRCODE    256
  544.  
  545. #ifndef YYIMPURE
  546. #define YYLEX        yylex()
  547. #endif
  548.  
  549. #ifndef YYPURE
  550. #define YYLEX        yylex(&yylval, &yylloc)
  551. #endif
  552.  
  553. /* If nonreentrant, generate the variables here */
  554.  
  555. #ifndef YYIMPURE
  556.  
  557. int    yychar;            /*  the lookahead symbol        */
  558. YYSTYPE    yylval;            /*  the semantic value of the        */
  559.                 /*  lookahead symbol            */
  560.  
  561. YYLTYPE yylloc;            /*  location data for the lookahead    */
  562.                 /*  symbol                */
  563.  
  564. int yynerrs;            /*  number of parse errors so far       */
  565. #endif  /* YYIMPURE */
  566.  
  567. #if YYDEBUG != 0
  568. int yydebug;            /*  nonzero means print parse trace    */
  569. /* Since this is uninitialized, it does not stop multiple parsers
  570.    from coexisting.  */
  571. #endif
  572.  
  573. /*  YYMAXDEPTH indicates the initial size of the parser's stacks    */
  574.  
  575. #ifndef    YYMAXDEPTH
  576. #define YYMAXDEPTH 200
  577. #endif
  578.  
  579. /*  YYMAXLIMIT is the maximum size the stacks can grow to
  580.     (effective only if the built-in stack extension method is used).  */
  581.  
  582. #ifndef YYMAXLIMIT
  583. #define YYMAXLIMIT 10000
  584. #endif
  585.  
  586.  
  587. #line 90 "bison.simple"
  588. int
  589. yyparse()
  590. {
  591.   register int yystate;
  592.   register int yyn;
  593.   register short *yyssp;
  594.   register YYSTYPE *yyvsp;
  595.   YYLTYPE *yylsp;
  596.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  597.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  598.  
  599.   short    yyssa[YYMAXDEPTH];    /*  the state stack            */
  600.   YYSTYPE yyvsa[YYMAXDEPTH];    /*  the semantic value stack        */
  601.   YYLTYPE yylsa[YYMAXDEPTH];    /*  the location stack            */
  602.  
  603.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  604.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  605.   YYLTYPE *yyls = yylsa;
  606.  
  607.   int yymaxdepth = YYMAXDEPTH;
  608.  
  609. #ifndef YYPURE
  610.   int yychar;
  611.   YYSTYPE yylval;
  612.   YYLTYPE yylloc;
  613.   int yynerrs;
  614. #endif
  615.  
  616.   YYSTYPE yyval;        /*  the variable used to return        */
  617.                 /*  semantic values from the action    */
  618.                 /*  routines                */
  619.  
  620.   int yylen;
  621.  
  622. #if YYDEBUG != 0
  623.   if (yydebug)
  624.     fprintf(stderr, "Starting parse\n");
  625. #endif
  626.  
  627.   yystate = 0;
  628.   yyerrstatus = 0;
  629.   yynerrs = 0;
  630.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  631.  
  632.   /* Initialize stack pointers.
  633.      Waste one element of value and location stack
  634.      so that they stay on the same level as the state stack.  */
  635.  
  636.   yyssp = yyss - 1;
  637.   yyvsp = yyvs;
  638.   yylsp = yyls;
  639.  
  640. /* Push a new state, which is found in  yystate  .  */
  641. /* In all cases, when you get here, the value and location stacks
  642.    have just been pushed. so pushing a state here evens the stacks.  */
  643. yynewstate:
  644.  
  645.   *++yyssp = yystate;
  646.  
  647.   if (yyssp >= yyss + yymaxdepth - 1)
  648.     {
  649.       /* Give user a chance to reallocate the stack */
  650.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  651.       YYSTYPE *yyvs1 = yyvs;
  652.       YYLTYPE *yyls1 = yyls;
  653.       short *yyss1 = yyss;
  654.  
  655.       /* Get the current used size of the three stacks, in elements.  */
  656.       int size = yyssp - yyss + 1;
  657.  
  658. #ifdef yyoverflow
  659.       /* Each stack pointer address is followed by the size of
  660.      the data in use in that stack, in bytes.  */
  661.       yyoverflow("parser stack overflow",
  662.          &yyss1, size * sizeof (*yyssp),
  663.          &yyvs1, size * sizeof (*yyvsp),
  664.          &yyls1, size * sizeof (*yylsp),
  665.          &yymaxdepth);
  666.  
  667.       yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  668. #else /* no yyoverflow */
  669.       /* Extend the stack our own way.  */
  670.       if (yymaxdepth >= YYMAXLIMIT)
  671.     yyerror("parser stack overflow");
  672.       yymaxdepth *= 2;
  673.       if (yymaxdepth > YYMAXLIMIT)
  674.     yymaxdepth = YYMAXLIMIT;
  675.       yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  676.       bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  677.       yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  678.       bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  679. #ifdef YYLSP_NEEDED
  680.       yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  681.       bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  682. #endif
  683. #endif /* no yyoverflow */
  684.  
  685.       yyssp = yyss + size - 1;
  686.       yyvsp = yyvs + size - 1;
  687. #ifdef YYLSP_NEEDED
  688.       yylsp = yyls + size - 1;
  689. #endif
  690.  
  691. #if YYDEBUG != 0
  692.       if (yydebug)
  693.     fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  694. #endif
  695.  
  696.       if (yyssp >= yyss + yymaxdepth - 1)
  697.     YYABORT;
  698.     }
  699.  
  700. #if YYDEBUG != 0
  701.   if (yydebug)
  702.     fprintf(stderr, "Entering state %d\n", yystate);
  703. #endif
  704.  
  705. /* Do appropriate processing given the current state.  */
  706. /* Read a lookahead token if we need one and don't already have one.  */
  707. yyresume:
  708.  
  709.   /* First try to decide what to do without reference to lookahead token.  */
  710.  
  711.   yyn = yypact[yystate];
  712.   if (yyn == YYFLAG)
  713.     goto yydefault;
  714.  
  715.   /* Not known => get a lookahead token if don't already have one.  */
  716.  
  717.   /* yychar is either YYEMPTY or YYEOF
  718.      or a valid token in external form.  */
  719.  
  720.   if (yychar == YYEMPTY)
  721.     {
  722. #if YYDEBUG != 0
  723.       if (yydebug)
  724.     fprintf(stderr, "Reading a token: ");
  725. #endif
  726.       yychar = YYLEX;
  727.     }
  728.  
  729.   /* Convert token to internal form (in yychar1) for indexing tables with */
  730.  
  731.   if (yychar <= 0)        /* This means end of input. */
  732.     {
  733.       yychar1 = 0;
  734.       yychar = YYEOF;        /* Don't call YYLEX any more */
  735.  
  736. #if YYDEBUG != 0
  737.       if (yydebug)
  738.     fprintf(stderr, "Now at end of input.\n");
  739. #endif
  740.     }
  741.   else
  742.     {
  743.       yychar1 = YYTRANSLATE(yychar);
  744.  
  745. #if YYDEBUG != 0
  746.       if (yydebug)
  747.     fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  748. #endif
  749.     }
  750.  
  751.   yyn += yychar1;
  752.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  753.     goto yydefault;
  754.  
  755.   yyn = yytable[yyn];
  756.  
  757.   /* yyn is what to do for this token type in this state.
  758.      Negative => reduce, -yyn is rule number.
  759.      Positive => shift, yyn is new state.
  760.        New state is final state => don't bother to shift,
  761.        just return success.
  762.      0, or most negative number => error.  */
  763.  
  764.   if (yyn < 0)
  765.     {
  766.       if (yyn == YYFLAG)
  767.     goto yyerrlab;
  768.       yyn = -yyn;
  769.       goto yyreduce;
  770.     }
  771.   else if (yyn == 0)
  772.     goto yyerrlab;
  773.  
  774.   if (yyn == YYFINAL)
  775.     YYACCEPT;
  776.  
  777.   /* Shift the lookahead token.  */
  778.  
  779. #if YYDEBUG != 0
  780.   if (yydebug)
  781.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  782. #endif
  783.  
  784.   /* Discard the token being shifted unless it is eof.  */
  785.   if (yychar != YYEOF)
  786.     yychar = YYEMPTY;
  787.  
  788.   *++yyvsp = yylval;
  789. #ifdef YYLSP_NEEDED
  790.   *++yylsp = yylloc;
  791. #endif
  792.  
  793.   /* count tokens shifted since error; after three, turn off error status.  */
  794.   if (yyerrstatus) yyerrstatus--;
  795.  
  796.   yystate = yyn;
  797.   goto yynewstate;
  798.  
  799. /* Do the default action for the current state.  */
  800. yydefault:
  801.  
  802.   yyn = yydefact[yystate];
  803.   if (yyn == 0)
  804.     goto yyerrlab;
  805.  
  806. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  807. yyreduce:
  808.   yylen = yyr2[yyn];
  809.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  810.  
  811. #if YYDEBUG != 0
  812.   if (yydebug)
  813.     {
  814.       if (yylen == 1)
  815.     fprintf (stderr, "Reducing 1 value via line %d, ",
  816.          yyrline[yyn]);
  817.       else
  818.     fprintf (stderr, "Reducing %d values via line %d, ",
  819.          yylen, yyrline[yyn]);
  820.     }
  821. #endif
  822.  
  823.  
  824.   switch (yyn) {
  825.  
  826. case 3:
  827. #line 188 "./m2-exp.y"
  828. { write_exp_elt_opcode(OP_TYPE);
  829.           write_exp_elt_type(yyvsp[0].tval);
  830.           write_exp_elt_opcode(OP_TYPE);
  831.         ;
  832.     break;}
  833. case 4:
  834. #line 197 "./m2-exp.y"
  835. { write_exp_elt_opcode (UNOP_IND); ;
  836.     break;}
  837. case 5:
  838. #line 200 "./m2-exp.y"
  839. { number_sign = -1; ;
  840.     break;}
  841. case 6:
  842. #line 202 "./m2-exp.y"
  843. { number_sign = 1;
  844.               write_exp_elt_opcode (UNOP_NEG); ;
  845.     break;}
  846. case 7:
  847. #line 207 "./m2-exp.y"
  848. { write_exp_elt_opcode(UNOP_PLUS); ;
  849.     break;}
  850. case 8:
  851. #line 211 "./m2-exp.y"
  852. { write_exp_elt_opcode (UNOP_ZEROP); ;
  853.     break;}
  854. case 11:
  855. #line 219 "./m2-exp.y"
  856. { write_exp_elt_opcode (UNOP_CAP); ;
  857.     break;}
  858. case 12:
  859. #line 223 "./m2-exp.y"
  860. { write_exp_elt_opcode (UNOP_ORD); ;
  861.     break;}
  862. case 13:
  863. #line 227 "./m2-exp.y"
  864. { write_exp_elt_opcode (UNOP_ABS); ;
  865.     break;}
  866. case 14:
  867. #line 231 "./m2-exp.y"
  868. { write_exp_elt_opcode (UNOP_HIGH); ;
  869.     break;}
  870. case 15:
  871. #line 235 "./m2-exp.y"
  872. { write_exp_elt_opcode (UNOP_MIN);
  873.               write_exp_elt_type (yyvsp[-1].tval);
  874.               write_exp_elt_opcode (UNOP_MIN); ;
  875.     break;}
  876. case 16:
  877. #line 241 "./m2-exp.y"
  878. { write_exp_elt_opcode (UNOP_MAX);
  879.               write_exp_elt_type (yyvsp[-1].tval);
  880.               write_exp_elt_opcode (UNOP_MIN); ;
  881.     break;}
  882. case 17:
  883. #line 247 "./m2-exp.y"
  884. { write_exp_elt_opcode (UNOP_FLOAT); ;
  885.     break;}
  886. case 18:
  887. #line 251 "./m2-exp.y"
  888. { write_exp_elt_opcode (BINOP_VAL);
  889.               write_exp_elt_type (yyvsp[-3].tval);
  890.               write_exp_elt_opcode (BINOP_VAL); ;
  891.     break;}
  892. case 19:
  893. #line 257 "./m2-exp.y"
  894. { write_exp_elt_opcode (UNOP_CHR); ;
  895.     break;}
  896. case 20:
  897. #line 261 "./m2-exp.y"
  898. { write_exp_elt_opcode (UNOP_ODD); ;
  899.     break;}
  900. case 21:
  901. #line 265 "./m2-exp.y"
  902. { write_exp_elt_opcode (UNOP_TRUNC); ;
  903.     break;}
  904. case 22:
  905. #line 269 "./m2-exp.y"
  906. { write_exp_elt_opcode (UNOP_SIZEOF); ;
  907.     break;}
  908. case 23:
  909. #line 274 "./m2-exp.y"
  910. { write_exp_elt_opcode(UNOP_PREINCREMENT); ;
  911.     break;}
  912. case 24:
  913. #line 278 "./m2-exp.y"
  914. { write_exp_elt_opcode(BINOP_ASSIGN_MODIFY);
  915.               write_exp_elt_opcode(BINOP_ADD);
  916.               write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); ;
  917.     break;}
  918. case 25:
  919. #line 284 "./m2-exp.y"
  920. { write_exp_elt_opcode(UNOP_PREDECREMENT);;
  921.     break;}
  922. case 26:
  923. #line 288 "./m2-exp.y"
  924. { write_exp_elt_opcode(BINOP_ASSIGN_MODIFY);
  925.               write_exp_elt_opcode(BINOP_SUB);
  926.               write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); ;
  927.     break;}
  928. case 27:
  929. #line 294 "./m2-exp.y"
  930. { write_exp_elt_opcode (STRUCTOP_STRUCT);
  931.               write_exp_string (yyvsp[0].sval);
  932.               write_exp_elt_opcode (STRUCTOP_STRUCT); ;
  933.     break;}
  934. case 29:
  935. #line 303 "./m2-exp.y"
  936. { error("Sets are not implemented.");;
  937.     break;}
  938. case 30:
  939. #line 307 "./m2-exp.y"
  940. { error("Sets are not implemented.");;
  941.     break;}
  942. case 31:
  943. #line 311 "./m2-exp.y"
  944. { error("Sets are not implemented.");;
  945.     break;}
  946. case 32:
  947. #line 314 "./m2-exp.y"
  948. { error("Sets are not implemented.");;
  949.     break;}
  950. case 33:
  951. #line 316 "./m2-exp.y"
  952. { error("Sets are not implemented.");;
  953.     break;}
  954. case 34:
  955. #line 325 "./m2-exp.y"
  956. { start_arglist(); ;
  957.     break;}
  958. case 35:
  959. #line 327 "./m2-exp.y"
  960. { write_exp_elt_opcode (BINOP_MULTI_SUBSCRIPT);
  961.               write_exp_elt_longcst ((LONGEST) end_arglist());
  962.               write_exp_elt_opcode (BINOP_MULTI_SUBSCRIPT); ;
  963.     break;}
  964. case 36:
  965. #line 335 "./m2-exp.y"
  966. { start_arglist (); ;
  967.     break;}
  968. case 37:
  969. #line 337 "./m2-exp.y"
  970. { write_exp_elt_opcode (OP_FUNCALL);
  971.               write_exp_elt_longcst ((LONGEST) end_arglist ());
  972.               write_exp_elt_opcode (OP_FUNCALL); ;
  973.     break;}
  974. case 39:
  975. #line 346 "./m2-exp.y"
  976. { arglist_len = 1; ;
  977.     break;}
  978. case 40:
  979. #line 350 "./m2-exp.y"
  980. { arglist_len++; ;
  981.     break;}
  982. case 41:
  983. #line 355 "./m2-exp.y"
  984. { arglist_len = 1; ;
  985.     break;}
  986. case 42:
  987. #line 360 "./m2-exp.y"
  988. { arglist_len++; ;
  989.     break;}
  990. case 43:
  991. #line 365 "./m2-exp.y"
  992. { write_exp_elt_opcode (UNOP_MEMVAL);
  993.               write_exp_elt_type (yyvsp[-2].tval);
  994.               write_exp_elt_opcode (UNOP_MEMVAL); ;
  995.     break;}
  996. case 44:
  997. #line 371 "./m2-exp.y"
  998. { write_exp_elt_opcode (UNOP_CAST);
  999.               write_exp_elt_type (yyvsp[-3].tval);
  1000.               write_exp_elt_opcode (UNOP_CAST); ;
  1001.     break;}
  1002. case 45:
  1003. #line 377 "./m2-exp.y"
  1004. { ;
  1005.     break;}
  1006. case 46:
  1007. #line 385 "./m2-exp.y"
  1008. { write_exp_elt_opcode (BINOP_REPEAT); ;
  1009.     break;}
  1010. case 47:
  1011. #line 389 "./m2-exp.y"
  1012. { write_exp_elt_opcode (BINOP_MUL); ;
  1013.     break;}
  1014. case 48:
  1015. #line 393 "./m2-exp.y"
  1016. { write_exp_elt_opcode (BINOP_DIV); ;
  1017.     break;}
  1018. case 49:
  1019. #line 397 "./m2-exp.y"
  1020. { write_exp_elt_opcode (BINOP_INTDIV); ;
  1021.     break;}
  1022. case 50:
  1023. #line 401 "./m2-exp.y"
  1024. { write_exp_elt_opcode (BINOP_REM); ;
  1025.     break;}
  1026. case 51:
  1027. #line 405 "./m2-exp.y"
  1028. { write_exp_elt_opcode (BINOP_ADD); ;
  1029.     break;}
  1030. case 52:
  1031. #line 409 "./m2-exp.y"
  1032. { write_exp_elt_opcode (BINOP_SUB); ;
  1033.     break;}
  1034. case 53:
  1035. #line 413 "./m2-exp.y"
  1036. { write_exp_elt_opcode (BINOP_EQUAL); ;
  1037.     break;}
  1038. case 54:
  1039. #line 417 "./m2-exp.y"
  1040. { write_exp_elt_opcode (BINOP_NOTEQUAL); ;
  1041.     break;}
  1042. case 55:
  1043. #line 419 "./m2-exp.y"
  1044. { write_exp_elt_opcode (BINOP_NOTEQUAL); ;
  1045.     break;}
  1046. case 56:
  1047. #line 423 "./m2-exp.y"
  1048. { write_exp_elt_opcode (BINOP_LEQ); ;
  1049.     break;}
  1050. case 57:
  1051. #line 427 "./m2-exp.y"
  1052. { write_exp_elt_opcode (BINOP_GEQ); ;
  1053.     break;}
  1054. case 58:
  1055. #line 431 "./m2-exp.y"
  1056. { write_exp_elt_opcode (BINOP_LESS); ;
  1057.     break;}
  1058. case 59:
  1059. #line 435 "./m2-exp.y"
  1060. { write_exp_elt_opcode (BINOP_GTR); ;
  1061.     break;}
  1062. case 60:
  1063. #line 439 "./m2-exp.y"
  1064. { write_exp_elt_opcode (BINOP_AND); ;
  1065.     break;}
  1066. case 61:
  1067. #line 443 "./m2-exp.y"
  1068. { write_exp_elt_opcode (BINOP_AND); ;
  1069.     break;}
  1070. case 62:
  1071. #line 447 "./m2-exp.y"
  1072. { write_exp_elt_opcode (BINOP_OR); ;
  1073.     break;}
  1074. case 63:
  1075. #line 451 "./m2-exp.y"
  1076. { write_exp_elt_opcode (BINOP_ASSIGN); ;
  1077.     break;}
  1078. case 64:
  1079. #line 458 "./m2-exp.y"
  1080. { write_exp_elt_opcode (OP_BOOL);
  1081.               write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval);
  1082.               write_exp_elt_opcode (OP_BOOL); ;
  1083.     break;}
  1084. case 65:
  1085. #line 464 "./m2-exp.y"
  1086. { write_exp_elt_opcode (OP_BOOL);
  1087.               write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval);
  1088.               write_exp_elt_opcode (OP_BOOL); ;
  1089.     break;}
  1090. case 66:
  1091. #line 470 "./m2-exp.y"
  1092. { write_exp_elt_opcode (OP_LONG);
  1093.               write_exp_elt_type (builtin_type_m2_int);
  1094.               write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
  1095.               write_exp_elt_opcode (OP_LONG); ;
  1096.     break;}
  1097. case 67:
  1098. #line 477 "./m2-exp.y"
  1099. {
  1100.               write_exp_elt_opcode (OP_LONG);
  1101.               write_exp_elt_type (builtin_type_m2_card);
  1102.               write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval);
  1103.               write_exp_elt_opcode (OP_LONG);
  1104.             ;
  1105.     break;}
  1106. case 68:
  1107. #line 486 "./m2-exp.y"
  1108. { write_exp_elt_opcode (OP_LONG);
  1109.               write_exp_elt_type (builtin_type_m2_char);
  1110.               write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval);
  1111.               write_exp_elt_opcode (OP_LONG); ;
  1112.     break;}
  1113. case 69:
  1114. #line 494 "./m2-exp.y"
  1115. { write_exp_elt_opcode (OP_DOUBLE);
  1116.               write_exp_elt_type (builtin_type_m2_real);
  1117.               write_exp_elt_dblcst (yyvsp[0].dval);
  1118.               write_exp_elt_opcode (OP_DOUBLE); ;
  1119.     break;}
  1120. case 71:
  1121. #line 505 "./m2-exp.y"
  1122. { write_exp_elt_opcode (OP_LAST);
  1123.               write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
  1124.               write_exp_elt_opcode (OP_LAST); ;
  1125.     break;}
  1126. case 72:
  1127. #line 511 "./m2-exp.y"
  1128. { write_exp_elt_opcode (OP_REGISTER);
  1129.               write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
  1130.               write_exp_elt_opcode (OP_REGISTER); ;
  1131.     break;}
  1132. case 73:
  1133. #line 517 "./m2-exp.y"
  1134. { write_exp_elt_opcode (OP_LONG);
  1135.               write_exp_elt_type (builtin_type_int);
  1136.               write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval));
  1137.               write_exp_elt_opcode (OP_LONG); ;
  1138.     break;}
  1139. case 74:
  1140. #line 524 "./m2-exp.y"
  1141. { write_exp_elt_opcode (OP_M2_STRING);
  1142.               write_exp_string (yyvsp[0].sval);
  1143.               write_exp_elt_opcode (OP_M2_STRING); ;
  1144.     break;}
  1145. case 75:
  1146. #line 531 "./m2-exp.y"
  1147. { yyval.bval = SYMBOL_BLOCK_VALUE(yyvsp[0].sym); ;
  1148.     break;}
  1149. case 76:
  1150. #line 535 "./m2-exp.y"
  1151. { struct symbol *sym
  1152.                 = lookup_symbol (copy_name (yyvsp[0].sval), expression_context_block,
  1153.                          VAR_NAMESPACE, 0, NULL);
  1154.               yyval.sym = sym;;
  1155.     break;}
  1156. case 77:
  1157. #line 544 "./m2-exp.y"
  1158. { struct symbol *tem
  1159.                 = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
  1160.                          VAR_NAMESPACE, 0, NULL);
  1161.               if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
  1162.                 error ("No function \"%s\" in specified context.",
  1163.                    copy_name (yyvsp[0].sval));
  1164.               yyval.sym = tem;
  1165.             ;
  1166.     break;}
  1167. case 78:
  1168. #line 556 "./m2-exp.y"
  1169. { write_exp_elt_opcode(OP_VAR_VALUE);
  1170.               write_exp_elt_sym (yyvsp[0].sym);
  1171.               write_exp_elt_opcode (OP_VAR_VALUE); ;
  1172.     break;}
  1173. case 79:
  1174. #line 563 "./m2-exp.y"
  1175. { write_exp_elt_opcode (OP_INTERNALVAR);
  1176.               write_exp_elt_intern (yyvsp[0].ivar);
  1177.               write_exp_elt_opcode (OP_INTERNALVAR); ;
  1178.     break;}
  1179. case 80:
  1180. #line 570 "./m2-exp.y"
  1181. { struct symbol *sym;
  1182.               sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
  1183.                            VAR_NAMESPACE, 0, NULL);
  1184.               if (sym == 0)
  1185.                 error ("No symbol \"%s\" in specified context.",
  1186.                    copy_name (yyvsp[0].sval));
  1187.  
  1188.               write_exp_elt_opcode (OP_VAR_VALUE);
  1189.               write_exp_elt_sym (sym);
  1190.               write_exp_elt_opcode (OP_VAR_VALUE); ;
  1191.     break;}
  1192. case 81:
  1193. #line 584 "./m2-exp.y"
  1194. { struct symbol *sym;
  1195.               int is_a_field_of_this;
  1196.  
  1197.                sym = lookup_symbol (copy_name (yyvsp[0].sval),
  1198.                            expression_context_block,
  1199.                            VAR_NAMESPACE,
  1200.                            &is_a_field_of_this,
  1201.                            NULL);
  1202.               if (sym)
  1203.                 {
  1204.                   switch (sym->class)
  1205.                 {
  1206.                 case LOC_REGISTER:
  1207.                 case LOC_ARG:
  1208.                 case LOC_LOCAL:
  1209.                 case LOC_REF_ARG:
  1210.                 case LOC_REGPARM:
  1211.                 case LOC_LOCAL_ARG:
  1212.                   if (innermost_block == 0 ||
  1213.                       contained_in (block_found,
  1214.                             innermost_block))
  1215.                     innermost_block = block_found;
  1216.                   break;
  1217.  
  1218.                 case LOC_UNDEF:
  1219.                 case LOC_CONST:
  1220.                 case LOC_STATIC:
  1221.                 case LOC_TYPEDEF:
  1222.                 case LOC_LABEL:    /* maybe should go above? */
  1223.                 case LOC_BLOCK:
  1224.                 case LOC_CONST_BYTES:
  1225.                   /* These are listed so gcc -Wall will reveal
  1226.                      un-handled cases.  */
  1227.                   break;
  1228.                 }
  1229.                   write_exp_elt_opcode (OP_VAR_VALUE);
  1230.                   write_exp_elt_sym (sym);
  1231.                   write_exp_elt_opcode (OP_VAR_VALUE);
  1232.                 }
  1233.               else
  1234.                 {
  1235.                   struct minimal_symbol *msymbol;
  1236.                   register char *arg = copy_name (yyvsp[0].sval);
  1237.  
  1238.                   msymbol = lookup_minimal_symbol (arg,
  1239.                       (struct objfile *) NULL);
  1240.                   if (msymbol != NULL)
  1241.                 {
  1242.                   write_exp_elt_opcode (OP_LONG);
  1243.                   write_exp_elt_type (builtin_type_int);
  1244.                   write_exp_elt_longcst ((LONGEST) msymbol -> address);
  1245.                   write_exp_elt_opcode (OP_LONG);
  1246.                   write_exp_elt_opcode (UNOP_MEMVAL);
  1247.                   if (msymbol -> type == mst_data ||
  1248.                       msymbol -> type == mst_bss)
  1249.                     write_exp_elt_type (builtin_type_int);
  1250.                   else if (msymbol -> type == mst_text)
  1251.                     write_exp_elt_type (lookup_function_type (builtin_type_int));
  1252.                   else
  1253.                     write_exp_elt_type (builtin_type_char);
  1254.                   write_exp_elt_opcode (UNOP_MEMVAL);
  1255.                 }
  1256.                   else if (!have_full_symbols () && !have_partial_symbols ())
  1257.                 error ("No symbol table is loaded.  Use the \"symbol-file\" command.");
  1258.                   else
  1259.                 error ("No symbol \"%s\" in current context.",
  1260.                        copy_name (yyvsp[0].sval));
  1261.                 }
  1262.             ;
  1263.     break;}
  1264. case 82:
  1265. #line 657 "./m2-exp.y"
  1266. { yyval.tval = lookup_typename (copy_name (yyvsp[0].sval),
  1267.                         expression_context_block, 0); ;
  1268.     break;}
  1269. }
  1270.    /* the action file gets copied in in place of this dollarsign */
  1271. #line 327 "bison.simple"
  1272.  
  1273.   yyvsp -= yylen;
  1274.   yyssp -= yylen;
  1275. #ifdef YYLSP_NEEDED
  1276.   yylsp -= yylen;
  1277. #endif
  1278.  
  1279. #if YYDEBUG != 0
  1280.   if (yydebug)
  1281.     {
  1282.       short *ssp1 = yyss - 1;
  1283.       fprintf (stderr, "state stack now");
  1284.       while (ssp1 != yyssp)
  1285.     fprintf (stderr, " %d", *++ssp1);
  1286.       fprintf (stderr, "\n");
  1287.     }
  1288. #endif
  1289.  
  1290.   *++yyvsp = yyval;
  1291.  
  1292. #ifdef YYLSP_NEEDED
  1293.   yylsp++;
  1294.   if (yylen == 0)
  1295.     {
  1296.       yylsp->first_line = yylloc.first_line;
  1297.       yylsp->first_column = yylloc.first_column;
  1298.       yylsp->last_line = (yylsp-1)->last_line;
  1299.       yylsp->last_column = (yylsp-1)->last_column;
  1300.       yylsp->text = 0;
  1301.     }
  1302.   else
  1303.     {
  1304.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1305.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1306.     }
  1307. #endif
  1308.  
  1309.   /* Now "shift" the result of the reduction.
  1310.      Determine what state that goes to,
  1311.      based on the state we popped back to
  1312.      and the rule number reduced by.  */
  1313.  
  1314.   yyn = yyr1[yyn];
  1315.  
  1316.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1317.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1318.     yystate = yytable[yystate];
  1319.   else
  1320.     yystate = yydefgoto[yyn - YYNTBASE];
  1321.  
  1322.   goto yynewstate;
  1323.  
  1324. yyerrlab:   /* here on detecting error */
  1325.  
  1326.   if (! yyerrstatus)
  1327.     /* If not already recovering from an error, report this error.  */
  1328.     {
  1329.       ++yynerrs;
  1330.       yyerror("parse error");
  1331.     }
  1332.  
  1333.   if (yyerrstatus == 3)
  1334.     {
  1335.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1336.  
  1337.       /* return failure if at end of input */
  1338.       if (yychar == YYEOF)
  1339.     YYABORT;
  1340.  
  1341. #if YYDEBUG != 0
  1342.       if (yydebug)
  1343.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1344. #endif
  1345.  
  1346.       yychar = YYEMPTY;
  1347.     }
  1348.  
  1349.   /* Else will try to reuse lookahead token
  1350.      after shifting the error token.  */
  1351.  
  1352.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1353.  
  1354.   goto yyerrhandle;
  1355.  
  1356. yyerrdefault:  /* current state does not do anything special for the error token. */
  1357.  
  1358. #if 0
  1359.   /* This is wrong; only states that explicitly want error tokens
  1360.      should shift them.  */
  1361.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1362.   if (yyn) goto yydefault;
  1363. #endif
  1364.  
  1365. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1366.  
  1367.   if (yyssp == yyss) YYABORT;
  1368.   yyvsp--;
  1369.   yystate = *--yyssp;
  1370. #ifdef YYLSP_NEEDED
  1371.   yylsp--;
  1372. #endif
  1373.  
  1374. #if YYDEBUG != 0
  1375.   if (yydebug)
  1376.     {
  1377.       short *ssp1 = yyss - 1;
  1378.       fprintf (stderr, "Error: state stack now");
  1379.       while (ssp1 != yyssp)
  1380.     fprintf (stderr, " %d", *++ssp1);
  1381.       fprintf (stderr, "\n");
  1382.     }
  1383. #endif
  1384.  
  1385. yyerrhandle:
  1386.  
  1387.   yyn = yypact[yystate];
  1388.   if (yyn == YYFLAG)
  1389.     goto yyerrdefault;
  1390.  
  1391.   yyn += YYTERROR;
  1392.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1393.     goto yyerrdefault;
  1394.  
  1395.   yyn = yytable[yyn];
  1396.   if (yyn < 0)
  1397.     {
  1398.       if (yyn == YYFLAG)
  1399.     goto yyerrpop;
  1400.       yyn = -yyn;
  1401.       goto yyreduce;
  1402.     }
  1403.   else if (yyn == 0)
  1404.     goto yyerrpop;
  1405.  
  1406.   if (yyn == YYFINAL)
  1407.     YYACCEPT;
  1408.  
  1409. #if YYDEBUG != 0
  1410.   if (yydebug)
  1411.     fprintf(stderr, "Shifting error token, ");
  1412. #endif
  1413.  
  1414.   *++yyvsp = yylval;
  1415. #ifdef YYLSP_NEEDED
  1416.   *++yylsp = yylloc;
  1417. #endif
  1418.  
  1419.   yystate = yyn;
  1420.   goto yynewstate;
  1421. }
  1422. #line 662 "./m2-exp.y"
  1423.  
  1424.  
  1425. #if 0  /* FIXME! */
  1426. int
  1427. overflow(a,b)
  1428.    long a,b;
  1429. {
  1430.    return (MAX_OF_TYPE(builtin_type_m2_int) - b) < a;
  1431. }
  1432.  
  1433. int
  1434. uoverflow(a,b)
  1435.    unsigned long a,b;
  1436. {
  1437.    return (MAX_OF_TYPE(builtin_type_m2_card) - b) < a;
  1438. }
  1439. #endif /* FIXME */
  1440.  
  1441. /* Take care of parsing a number (anything that starts with a digit).
  1442.    Set yylval and return the token type; update lexptr.
  1443.    LEN is the number of characters in it.  */
  1444.  
  1445. /*** Needs some error checking for the float case ***/
  1446.  
  1447. static int
  1448. parse_number (olen)
  1449.      int olen;
  1450. {
  1451.   register char *p = lexptr;
  1452.   register LONGEST n = 0;
  1453.   register LONGEST prevn = 0;
  1454.   register int c,i,ischar=0;
  1455.   register int base = input_radix;
  1456.   register int len = olen;
  1457.   int unsigned_p = number_sign == 1 ? 1 : 0;
  1458.  
  1459.   if(p[len-1] == 'H')
  1460.   {
  1461.      base = 16;
  1462.      len--;
  1463.   }
  1464.   else if(p[len-1] == 'C' || p[len-1] == 'B')
  1465.   {
  1466.      base = 8;
  1467.      ischar = p[len-1] == 'C';
  1468.      len--;
  1469.   }
  1470.  
  1471.   /* Scan the number */
  1472.   for (c = 0; c < len; c++)
  1473.   {
  1474.     if (p[c] == '.' && base == 10)
  1475.       {
  1476.     /* It's a float since it contains a point.  */
  1477.     yylval.dval = atof (p);
  1478.     lexptr += len;
  1479.     return FLOAT;
  1480.       }
  1481.     if (p[c] == '.' && base != 10)
  1482.        error("Floating point numbers must be base 10.");
  1483.     if (base == 10 && (p[c] < '0' || p[c] > '9'))
  1484.        error("Invalid digit \'%c\' in number.",p[c]);
  1485.  }
  1486.  
  1487.   while (len-- > 0)
  1488.     {
  1489.       c = *p++;
  1490.       n *= base;
  1491.       if( base == 8 && (c == '8' || c == '9'))
  1492.      error("Invalid digit \'%c\' in octal number.",c);
  1493.       if (c >= '0' && c <= '9')
  1494.     i = c - '0';
  1495.       else
  1496.     {
  1497.       if (base == 16 && c >= 'A' && c <= 'F')
  1498.         i = c - 'A' + 10;
  1499.       else
  1500.          return ERROR;
  1501.     }
  1502.       n+=i;
  1503.       if(i >= base)
  1504.      return ERROR;
  1505.       if(!unsigned_p && number_sign == 1 && (prevn >= n))
  1506.      unsigned_p=1;        /* Try something unsigned */
  1507.       /* Don't do the range check if n==i and i==0, since that special
  1508.      case will give an overflow error. */
  1509.       if(RANGE_CHECK && n!=i && i)
  1510.       {
  1511.      if((unsigned_p && (unsigned)prevn >= (unsigned)n) ||
  1512.         ((!unsigned_p && number_sign==-1) && -prevn <= -n))
  1513.         range_error("Overflow on numeric constant.");
  1514.       }
  1515.      prevn=n;
  1516.     }
  1517.  
  1518.   lexptr = p;
  1519.   if(*p == 'B' || *p == 'C' || *p == 'H')
  1520.      lexptr++;            /* Advance past B,C or H */
  1521.  
  1522.   if (ischar)
  1523.   {
  1524.      yylval.ulval = n;
  1525.      return CHAR;
  1526.   }
  1527.   else if ( unsigned_p && number_sign == 1)
  1528.   {
  1529.      yylval.ulval = n;
  1530.      return UINT;
  1531.   }
  1532.   else if((unsigned_p && (n<0))) {
  1533.      range_error("Overflow on numeric constant -- number too large.");
  1534.      /* But, this can return if range_check == range_warn.  */
  1535.   }
  1536.   yylval.lval = n;
  1537.   return INT;
  1538. }
  1539.  
  1540.  
  1541. /* Some tokens */
  1542.  
  1543. static struct
  1544. {
  1545.    char name[2];
  1546.    int token;
  1547. } tokentab2[] =
  1548. {
  1549.     {"<>",    NOTEQUAL      },
  1550.     {":=",    ASSIGN     },
  1551.     {"<=",    LEQ     },
  1552.     {">=",    GEQ     },
  1553.     {"::",    COLONCOLON },
  1554.  
  1555. };
  1556.  
  1557. /* Some specific keywords */
  1558.  
  1559. struct keyword {
  1560.    char keyw[10];
  1561.    int token;
  1562. };
  1563.  
  1564. static struct keyword keytab[] =
  1565. {
  1566.     {"OR" ,   OROR     },
  1567.     {"IN",    IN         },/* Note space after IN */
  1568.     {"AND",   ANDAND     },
  1569.     {"ABS",   ABS     },
  1570.     {"CHR",   CHR     },
  1571.     {"DEC",   DEC     },
  1572.     {"NOT",   NOT     },
  1573.     {"DIV",   DIV         },
  1574.     {"INC",   INC     },
  1575.     {"MAX",   MAX_FUNC     },
  1576.     {"MIN",   MIN_FUNC     },
  1577.     {"MOD",   MOD     },
  1578.     {"ODD",   ODD     },
  1579.     {"CAP",   CAP     },
  1580.     {"ORD",   ORD     },
  1581.     {"VAL",   VAL     },
  1582.     {"EXCL",  EXCL     },
  1583.     {"HIGH",  HIGH       },
  1584.     {"INCL",  INCL     },
  1585.     {"SIZE",  SIZE       },
  1586.     {"FLOAT", FLOAT_FUNC },
  1587.     {"TRUNC", TRUNC     },
  1588. };
  1589.  
  1590.  
  1591. /* Read one token, getting characters through lexptr.  */
  1592.  
  1593. /* This is where we will check to make sure that the language and the operators used are
  1594.    compatible  */
  1595.  
  1596. static int
  1597. yylex ()
  1598. {
  1599.   register int c;
  1600.   register int namelen;
  1601.   register int i;
  1602.   register char *tokstart;
  1603.   register char quote;
  1604.  
  1605.  retry:
  1606.  
  1607.   tokstart = lexptr;
  1608.  
  1609.  
  1610.   /* See if it is a special token of length 2 */
  1611.   for( i = 0 ; i < sizeof tokentab2 / sizeof tokentab2[0] ; i++)
  1612.      if(!strncmp(tokentab2[i].name, tokstart, 2))
  1613.      {
  1614.     lexptr += 2;
  1615.     return tokentab2[i].token;
  1616.      }
  1617.  
  1618.   switch (c = *tokstart)
  1619.     {
  1620.     case 0:
  1621.       return 0;
  1622.  
  1623.     case ' ':
  1624.     case '\t':
  1625.     case '\n':
  1626.       lexptr++;
  1627.       goto retry;
  1628.  
  1629.     case '(':
  1630.       paren_depth++;
  1631.       lexptr++;
  1632.       return c;
  1633.  
  1634.     case ')':
  1635.       if (paren_depth == 0)
  1636.     return 0;
  1637.       paren_depth--;
  1638.       lexptr++;
  1639.       return c;
  1640.  
  1641.     case ',':
  1642.       if (comma_terminates && paren_depth == 0)
  1643.     return 0;
  1644.       lexptr++;
  1645.       return c;
  1646.  
  1647.     case '.':
  1648.       /* Might be a floating point number.  */
  1649.       if (lexptr[1] >= '0' && lexptr[1] <= '9')
  1650.     break;            /* Falls into number code.  */
  1651.       else
  1652.       {
  1653.      lexptr++;
  1654.      return DOT;
  1655.       }
  1656.  
  1657. /* These are character tokens that appear as-is in the YACC grammar */
  1658.     case '+':
  1659.     case '-':
  1660.     case '*':
  1661.     case '/':
  1662.     case '^':
  1663.     case '<':
  1664.     case '>':
  1665.     case '[':
  1666.     case ']':
  1667.     case '=':
  1668.     case '{':
  1669.     case '}':
  1670.     case '#':
  1671.     case '@':
  1672.     case '~':
  1673.     case '&':
  1674.       lexptr++;
  1675.       return c;
  1676.  
  1677.     case '\'' :
  1678.     case '"':
  1679.       quote = c;
  1680.       for (namelen = 1; (c = tokstart[namelen]) != quote && c != '\0'; namelen++)
  1681.     if (c == '\\')
  1682.       {
  1683.         c = tokstart[++namelen];
  1684.         if (c >= '0' && c <= '9')
  1685.           {
  1686.         c = tokstart[++namelen];
  1687.         if (c >= '0' && c <= '9')
  1688.           c = tokstart[++namelen];
  1689.           }
  1690.       }
  1691.       if(c != quote)
  1692.      error("Unterminated string or character constant.");
  1693.       yylval.sval.ptr = tokstart + 1;
  1694.       yylval.sval.length = namelen - 1;
  1695.       lexptr += namelen + 1;
  1696.  
  1697.       if(namelen == 2)      /* Single character */
  1698.       {
  1699.        yylval.ulval = tokstart[1];
  1700.        return CHAR;
  1701.       }
  1702.       else
  1703.      return STRING;
  1704.     }
  1705.  
  1706.   /* Is it a number?  */
  1707.   /* Note:  We have already dealt with the case of the token '.'.
  1708.      See case '.' above.  */
  1709.   if ((c >= '0' && c <= '9'))
  1710.     {
  1711.       /* It's a number.  */
  1712.       int got_dot = 0, got_e = 0;
  1713.       register char *p = tokstart;
  1714.       int toktype;
  1715.  
  1716.       for (++p ;; ++p)
  1717.     {
  1718.       if (!got_e && (*p == 'e' || *p == 'E'))
  1719.         got_dot = got_e = 1;
  1720.       else if (!got_dot && *p == '.')
  1721.         got_dot = 1;
  1722.       else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
  1723.            && (*p == '-' || *p == '+'))
  1724.         /* This is the sign of the exponent, not the end of the
  1725.            number.  */
  1726.         continue;
  1727.       else if ((*p < '0' || *p > '9') &&
  1728.            (*p < 'A' || *p > 'F') &&
  1729.            (*p != 'H'))  /* Modula-2 hexadecimal number */
  1730.         break;
  1731.     }
  1732.     toktype = parse_number (p - tokstart);
  1733.         if (toktype == ERROR)
  1734.       {
  1735.         char *err_copy = (char *) alloca (p - tokstart + 1);
  1736.  
  1737.         bcopy (tokstart, err_copy, p - tokstart);
  1738.         err_copy[p - tokstart] = 0;
  1739.         error ("Invalid number \"%s\".", err_copy);
  1740.       }
  1741.     lexptr = p;
  1742.     return toktype;
  1743.     }
  1744.  
  1745.   if (!(c == '_' || c == '$'
  1746.     || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
  1747.     /* We must have come across a bad character (e.g. ';').  */
  1748.     error ("Invalid character '%c' in expression.", c);
  1749.  
  1750.   /* It's a name.  See how long it is.  */
  1751.   namelen = 0;
  1752.   for (c = tokstart[namelen];
  1753.        (c == '_' || c == '$' || (c >= '0' && c <= '9')
  1754.     || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
  1755.        c = tokstart[++namelen])
  1756.     ;
  1757.  
  1758.   /* The token "if" terminates the expression and is NOT
  1759.      removed from the input stream.  */
  1760.   if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f')
  1761.     {
  1762.       return 0;
  1763.     }
  1764.  
  1765.   lexptr += namelen;
  1766.  
  1767.   /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
  1768.      and $$digits (equivalent to $<-digits> if you could type that).
  1769.      Make token type LAST, and put the number (the digits) in yylval.  */
  1770.  
  1771.   if (*tokstart == '$')
  1772.     {
  1773.       register int negate = 0;
  1774.       c = 1;
  1775.       /* Double dollar means negate the number and add -1 as well.
  1776.      Thus $$ alone means -1.  */
  1777.       if (namelen >= 2 && tokstart[1] == '$')
  1778.     {
  1779.       negate = 1;
  1780.       c = 2;
  1781.     }
  1782.       if (c == namelen)
  1783.     {
  1784.       /* Just dollars (one or two) */
  1785.       yylval.lval = - negate;
  1786.       return LAST;
  1787.     }
  1788.       /* Is the rest of the token digits?  */
  1789.       for (; c < namelen; c++)
  1790.     if (!(tokstart[c] >= '0' && tokstart[c] <= '9'))
  1791.       break;
  1792.       if (c == namelen)
  1793.     {
  1794.       yylval.lval = atoi (tokstart + 1 + negate);
  1795.       if (negate)
  1796.         yylval.lval = - yylval.lval;
  1797.       return LAST;
  1798.     }
  1799.     }
  1800.  
  1801.   /* Handle tokens that refer to machine registers:
  1802.      $ followed by a register name.  */
  1803.  
  1804.   if (*tokstart == '$') {
  1805.     for (c = 0; c < NUM_REGS; c++)
  1806.       if (namelen - 1 == strlen (reg_names[c])
  1807.       && !strncmp (tokstart + 1, reg_names[c], namelen - 1))
  1808.     {
  1809.       yylval.lval = c;
  1810.       return REGNAME;
  1811.     }
  1812.     for (c = 0; c < num_std_regs; c++)
  1813.      if (namelen - 1 == strlen (std_regs[c].name)
  1814.      && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1))
  1815.        {
  1816.      yylval.lval = std_regs[c].regnum;
  1817.      return REGNAME;
  1818.        }
  1819.   }
  1820.  
  1821.  
  1822.   /*  Lookup special keywords */
  1823.   for(i = 0 ; i < sizeof(keytab) / sizeof(keytab[0]) ; i++)
  1824.      if(namelen == strlen(keytab[i].keyw) && !strncmp(tokstart,keytab[i].keyw,namelen))
  1825.        return keytab[i].token;
  1826.  
  1827.   yylval.sval.ptr = tokstart;
  1828.   yylval.sval.length = namelen;
  1829.  
  1830.   /* Any other names starting in $ are debugger internal variables.  */
  1831.  
  1832.   if (*tokstart == '$')
  1833.     {
  1834.       yylval.ivar = (struct internalvar *) lookup_internalvar (copy_name (yylval.sval) + 1);
  1835.       return INTERNAL_VAR;
  1836.     }
  1837.  
  1838.  
  1839.   /* Use token-type BLOCKNAME for symbols that happen to be defined as
  1840.      functions.  If this is not so, then ...
  1841.      Use token-type TYPENAME for symbols that happen to be defined
  1842.      currently as names of types; NAME for other symbols.
  1843.      The caller is not constrained to care about the distinction.  */
  1844.  {
  1845.  
  1846.  
  1847.     char *tmp = copy_name (yylval.sval);
  1848.     struct symbol *sym;
  1849.  
  1850.     if (lookup_partial_symtab (tmp))
  1851.       return BLOCKNAME;
  1852.     sym = lookup_symbol (tmp, expression_context_block,
  1853.              VAR_NAMESPACE, 0, NULL);
  1854.     if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
  1855.       return BLOCKNAME;
  1856.     if (lookup_typename (copy_name (yylval.sval), expression_context_block, 1))
  1857.       return TYPENAME;
  1858.  
  1859.     if(sym)
  1860.     {
  1861.        switch(sym->class)
  1862.        {
  1863.        case LOC_STATIC:
  1864.        case LOC_REGISTER:
  1865.        case LOC_ARG:
  1866.        case LOC_REF_ARG:
  1867.        case LOC_REGPARM:
  1868.        case LOC_LOCAL:
  1869.        case LOC_LOCAL_ARG:
  1870.        case LOC_CONST:
  1871.        case LOC_CONST_BYTES:
  1872.       return NAME;
  1873.  
  1874.        case LOC_TYPEDEF:
  1875.       return TYPENAME;
  1876.  
  1877.        case LOC_BLOCK:
  1878.       return BLOCKNAME;
  1879.  
  1880.        case LOC_UNDEF:
  1881.       error("internal:  Undefined class in m2lex()");
  1882.  
  1883.        case LOC_LABEL:
  1884.       error("internal:  Unforseen case in m2lex()");
  1885.        }
  1886.     }
  1887.     else
  1888.     {
  1889.        /* Built-in BOOLEAN type.  This is sort of a hack. */
  1890.        if(!strncmp(tokstart,"TRUE",4))
  1891.        {
  1892.       yylval.ulval = 1;
  1893.       return TRUE;
  1894.        }
  1895.        else if(!strncmp(tokstart,"FALSE",5))
  1896.        {
  1897.       yylval.ulval = 0;
  1898.       return FALSE;
  1899.        }
  1900.     }
  1901.  
  1902.     /* Must be another type of name... */
  1903.     return NAME;
  1904.  }
  1905. }
  1906.  
  1907. #if 0        /* Unused */
  1908. static char *
  1909. make_qualname(mod,ident)
  1910.    char *mod, *ident;
  1911. {
  1912.    char *new = xmalloc(strlen(mod)+strlen(ident)+2);
  1913.  
  1914.    strcpy(new,mod);
  1915.    strcat(new,".");
  1916.    strcat(new,ident);
  1917.    return new;
  1918. }
  1919. #endif  /* 0 */
  1920.  
  1921. static void
  1922. yyerror(msg)
  1923.      char *msg;    /* unused */
  1924. {
  1925.    printf("Parsing:  %s\n",lexptr);
  1926.    if (yychar < 256)
  1927.      error("Invalid syntax in expression near character '%c'.",yychar);
  1928.    else
  1929.      error("Invalid syntax in expression");
  1930. }
  1931.  
  1932. /* Table of operators and their precedences for printing expressions.  */
  1933.  
  1934. const static struct op_print m2_op_print_tab[] = {
  1935.     {"+",   BINOP_ADD, PREC_ADD, 0},
  1936.     {"+",   UNOP_PLUS, PREC_PREFIX, 0},
  1937.     {"-",   BINOP_SUB, PREC_ADD, 0},
  1938.     {"-",   UNOP_NEG, PREC_PREFIX, 0},
  1939.     {"*",   BINOP_MUL, PREC_MUL, 0},
  1940.     {"/",   BINOP_DIV, PREC_MUL, 0},
  1941.     {"DIV", BINOP_INTDIV, PREC_MUL, 0},
  1942.     {"MOD", BINOP_REM, PREC_MUL, 0},
  1943.     {":=",  BINOP_ASSIGN, PREC_ASSIGN, 1},
  1944.     {"OR",  BINOP_OR, PREC_OR, 0},
  1945.     {"AND", BINOP_AND, PREC_AND, 0},
  1946.     {"NOT", UNOP_ZEROP, PREC_PREFIX, 0},
  1947.     {"=",   BINOP_EQUAL, PREC_EQUAL, 0},
  1948.     {"<>",  BINOP_NOTEQUAL, PREC_EQUAL, 0},
  1949.     {"<=",  BINOP_LEQ, PREC_ORDER, 0},
  1950.     {">=",  BINOP_GEQ, PREC_ORDER, 0},
  1951.     {">",   BINOP_GTR, PREC_ORDER, 0},
  1952.     {"<",   BINOP_LESS, PREC_ORDER, 0},
  1953.     {"^",   UNOP_IND, PREC_PREFIX, 0},
  1954.     {"@",   BINOP_REPEAT, PREC_REPEAT, 0},
  1955. };
  1956.  
  1957. /* The built-in types of Modula-2.  */
  1958.  
  1959. struct type *builtin_type_m2_char;
  1960. struct type *builtin_type_m2_int;
  1961. struct type *builtin_type_m2_card;
  1962. struct type *builtin_type_m2_real;
  1963. struct type *builtin_type_m2_bool;
  1964.  
  1965. struct type ** const (m2_builtin_types[]) = 
  1966. {
  1967.   &builtin_type_m2_char,
  1968.   &builtin_type_m2_int,
  1969.   &builtin_type_m2_card,
  1970.   &builtin_type_m2_real,
  1971.   &builtin_type_m2_bool,
  1972.   0
  1973. };
  1974.  
  1975. const struct language_defn m2_language_defn = {
  1976.   "modula-2",
  1977.   language_m2,
  1978.   m2_builtin_types,
  1979.   range_check_on,
  1980.   type_check_on,
  1981.   m2_parse,            /* parser */
  1982.   m2_error,            /* parser error function */
  1983.   &builtin_type_m2_int,        /* longest signed   integral type */
  1984.   &builtin_type_m2_card,        /* longest unsigned integral type */
  1985.   &builtin_type_m2_real,        /* longest floating point type */
  1986.   "0%XH", "0%", "XH",        /* Hex   format string, prefix, suffix */
  1987.   "%oB",  "%",  "oB",        /* Octal format string, prefix, suffix */
  1988.   m2_op_print_tab,        /* expression operators for printing */
  1989.   LANG_MAGIC
  1990. };
  1991.  
  1992. /* Initialization for Modula-2 */
  1993.  
  1994. void
  1995. _initialize_m2_exp ()
  1996. {
  1997.   /* FIXME:  The code below assumes that the sizes of the basic data
  1998.      types are the same on the host and target machines!!!  */
  1999.  
  2000.   /* Modula-2 "pervasive" types.  NOTE:  these can be redefined!!! */
  2001.   builtin_type_m2_int =
  2002.     init_type (TYPE_CODE_INT, sizeof(int), 0,
  2003.            "INTEGER", (struct objfile *) NULL);
  2004.   builtin_type_m2_card =
  2005.     init_type (TYPE_CODE_INT, sizeof(int), TYPE_FLAG_UNSIGNED,
  2006.            "CARDINAL", (struct objfile *) NULL);
  2007.   builtin_type_m2_real =
  2008.     init_type (TYPE_CODE_FLT, sizeof(float), 0,
  2009.            "REAL", (struct objfile *) NULL);
  2010.   builtin_type_m2_char =
  2011.     init_type (TYPE_CODE_CHAR, sizeof(char), TYPE_FLAG_UNSIGNED,
  2012.            "CHAR", (struct objfile *) NULL);
  2013.   builtin_type_m2_bool =
  2014.     init_type (TYPE_CODE_BOOL, sizeof(int), TYPE_FLAG_UNSIGNED,
  2015.            "BOOLEAN", (struct objfile *) NULL);
  2016.  
  2017.   TYPE_NFIELDS(builtin_type_m2_bool) = 2;
  2018.   TYPE_FIELDS(builtin_type_m2_bool) = 
  2019.      (struct field *) malloc (sizeof (struct field) * 2);
  2020.   TYPE_FIELD_BITPOS(builtin_type_m2_bool,0) = 0;
  2021.   TYPE_FIELD_NAME(builtin_type_m2_bool,0) = (char *)malloc(6);
  2022.   strcpy(TYPE_FIELD_NAME(builtin_type_m2_bool,0),"FALSE");
  2023.   TYPE_FIELD_BITPOS(builtin_type_m2_bool,1) = 1;
  2024.   TYPE_FIELD_NAME(builtin_type_m2_bool,1) = (char *)malloc(5);
  2025.   strcpy(TYPE_FIELD_NAME(builtin_type_m2_bool,1),"TRUE");
  2026.  
  2027.   add_language (&m2_language_defn);
  2028. }
  2029.